import Vue from "vue";
import VueRouter from "vue-router";
import HomeView from "../views/HomeView.vue";

Vue.use(VueRouter);

const routes = [
  {
    path: "/",
    name: "home",
    component: HomeView,
    redirect: "/container",
    children: [
      {
        path: "/container",
        name: "container",
        component: () => import("../components/ContAiner.vue"),
      },
      {
        path: "/cate",
        name: "cate",
        component: () => import("../components/categroy/CateView.vue"),
      },
      {
        path: "/cate/sub",
        name: "catesub",
        component: () => import("../components/subcategory/SubIndex.vue"),
      },
      {
        path: "detail",
        name: "detail",
        component: () => import("../components/goodsdetail/DetailView.vue"),
      },
    ],
  },
  {
    path: "/about",
    name: "about",
    component: () => import("../views/AboutView.vue"),
  },
  {
    path: "/nopage",
    name: "nopage",
    component: () => import("../views/NoPage.vue"),
  },
  {
    path: "/lunbo",
    name: "lunbo",
    component: () => import("../components/index/LunBo.vue"),
  },
];

const router = new VueRouter({
  mode: "history",
  routes,
  scrollBehavior() {
    return { x: 0, y: 0 };
  },
});

// router.beforeEach((to,form,next)=>{
//   console.log(to);
//   console.log(form);
//   next()
// })

export default router;
